]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
notification-daemon: Add support for 'default' actions
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 2 Aug 2011 13:42:45 +0000 (15:42 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Wed, 3 Aug 2011 18:07:50 +0000 (20:07 +0200)
The notification spec supports the concept of a 'default' action:
  "The default action (usually invoked my clicking the notification)
   should have a key named "default". The name can be anything, though
   implementations are free not to display it."
Support this by invoking the 'default' action rather than a emitting
the 'clicked' signal when clicking notifications which specifie a
default action.
Also don't add an action button for the default action.

https://bugzilla.gnome.org/show_bug.cgi?id=655818

js/ui/notificationDaemon.js

index d6053e2c69a632a9075e9aae55a23fb3c395640a..8401c9e9acb3cd89680f7dd5abd56541626e5b49 100644 (file)
@@ -331,8 +331,15 @@ NotificationDaemon.prototype = {
 
         if (actions.length) {
             notification.setUseActionIcons(hints['action-icons'] == true);
-            for (let i = 0; i < actions.length - 1; i += 2)
-                notification.addButton(actions[i], actions[i + 1]);
+            for (let i = 0; i < actions.length - 1; i += 2) {
+                if (actions[i] == 'default')
+                    notification.connect('clicked', Lang.bind(this,
+                        function() {
+                            this._emitActionInvoked(id, "default");
+                        });
+                else
+                    notification.addButton(actions[i], actions[i + 1]);
+            }
         }
         switch (hints.urgency) {
             case Urgency.LOW: